package cn.befory;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 项目启动类
 * @author befory
 * @since 2019-08-19
 */
@SpringBootApplication
@MapperScan("cn.befory.dao")
@EnableWebMvc
public class CrmApplication implements WebMvcConfigurer
{
    /**
     * 配置静态访问资源
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
//        registry.addResourceHandler("swagger-ui.html")
//                .addResourceLocations("classpath:/META-INF/resources/");
//        registry.addResourceHandler("/webjars/**")
//                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
    @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("login").setViewName("login");
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/index_v1").setViewName("index_v1");
        registry.addViewController("/user/index").setViewName("user/index");
        registry.addViewController("/user/toAdd").setViewName("user/add");
        registry.addViewController("/perm/toAdd").setViewName("perm/add");
    }
    public static void main( String[] args )
    {
        SpringApplication.run(CrmApplication.class,args);
    }
}
